package org.example.mall.admin.model.entity.marketing;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.example.mall.admin.configuration.file.Url;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * <p>
 * 文章管理
 * </p>
 *
 * @author hzq
 * @since 2022-01-12
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("article")
@ApiModel(value = "Article对象", description = "文章管理")
public class Article extends Model<Article> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "文章id")
    @TableId(value = "article_id", type = IdType.AUTO)
    private Integer articleId;

    @NotBlank(message = "标题不能为空")
    @Length(max = 64, message = "标题不能超过64个字符")
    @ApiModelProperty(value = "标题")
    @TableField("title")
    private String title;

    @Url
    @ApiModelProperty(value = "封面图")
    @TableField("cover_picture")
    private String coverPicture;

    @Length(max = 255, message = "简介不能超过255个字符")
    @ApiModelProperty(value = "简介")
    @TableField("introduction")
    private String introduction;

    // @Url(Url.Type.TEXT) 可以使用富文本的方式
    @ApiModelProperty(value = "富文本内容")
    @TableField("content")
    private String content;

    @Url
    @ApiModelProperty(value = "富文本素材列表逗号分割")
    @TableField("content_urls")
    private String contentUrls;

    @ApiModelProperty(value = "标签")
    @TableField("label")
    private String label;

    @ApiModelProperty(value = "分类")
    @TableField("classification")
    private String classification;

    @Length(max = 32, message = "作者名称不能超过32个字符")
    @ApiModelProperty(value = "作者")
    @TableField("author")
    private String author;

    @ApiModelProperty(value = "创建时间")
    @TableField("create_time")
    private LocalDateTime createTime;

    @ApiModelProperty(value = "修改时间")
    @TableField("update_time")
    private LocalDateTime updateTime;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @ApiModelProperty(value = "是否已同步最新数据状态到ES中（1是0否）")
    @TableField("sync_es_status")
    private String syncEsStatus;


    @Override
    protected Serializable pkVal() {
        return this.articleId;
    }

}
